package top.foxhome.productimages.productimages;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

public class TextUtil {
    /**
     * 生成一个新的文件名称
     *
     * @param width
     * @param height
     * @return
     */
    public static String getNewFileName(int width, int height, String fileName) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        int fiveDigitNumber = 10000 + (int) (Math.random() * 90000);
        String formatted = String.format("%05d", fiveDigitNumber);
        fileName = fileName.substring(fileName.lastIndexOf("."));
        return String.format("%d_%d_%s_%s%s", width, height, sdf.format(new Date()), formatted, fileName);
    }
}
